package cn.bj.yu.function;

import java.util.function.Predicate;

/**
 * @author 周宇
 * @create 2020-08-14 15:55
 * 断定型接口：有一个输入参数 返回值是Boolean
 */
public class PredicateDemo {
    public static void main(String[] args) {
        //判断字符串是否为空
        Predicate<String> predicate = new Predicate<String>() {
            @Override
            public boolean test(String s) {
                return s.isEmpty();
            }
        };
        //lambda优化
        Predicate<String> lpredicate = (str) -> {
            return str.isEmpty();
        };
        System.out.println(predicate.test("asd"));
        System.out.println(lpredicate.test(""));
    }
}
